package com.huang.foundation.endpoint;

import com.huang.entity.result.HStringResult;
import com.huang.entity.result.ResultBuilder;
import com.huang.foundation.entity.request.SensitiveWordsCheckParam;
import com.huang.foundation.service.SensitiveWordsService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author HuangShen
 * @Date 2022/3/2 08:19
 * @Describe
 */
@RestController(value = "sensitiveWordsApi")
public class SensitiveWordsEndpoint implements SensitiveWordsApi {

    @Resource
    private SensitiveWordsService sensitiveWordsService;
    @Override
    public HStringResult<List<String>> SensitiveWordsCheck(SensitiveWordsCheckParam sensitiveWordsCheckParam) {
        List<String> sensitiveWordsMatch = sensitiveWordsService.sensitiveWordsMatch(sensitiveWordsCheckParam.getText());
        return ResultBuilder.successHSingle(sensitiveWordsMatch);
    }

    @Override
    public HStringResult<String> SensitiveWordsReplace(SensitiveWordsCheckParam sensitiveWordsCheckParam) {
        String replaceText = sensitiveWordsService.sensitiveWordsReplace(sensitiveWordsCheckParam.getText());
        return ResultBuilder.successHSingle(replaceText);
    }
}
